CURSOR/FETCH vs LIMIT/OFFSET

Поиск
Список
Период
Сортировка
От Charles Hauser
Тема CURSOR/FETCH vs LIMIT/OFFSET
Дата
Msg-id a05010402b8fef1752c72@[152.3.11.193]
обсуждение исходный текст
Ответы Re: CURSOR/FETCH vs LIMIT/OFFSET  (Philip Hallstrom <philip@adhesivemedia.com>)
Список pgsql-sql
Hi,

re: displaying results of query.

Trying to work out details of how to let users page back and forth 
among a multi-page list of results.

Problem: I need to know the total number of tuples the query would 
return in order to decide if there are more to display.

1) Use CURSOR and FETCH

$res= $con->exec("BEGIN WORK;DECLARE gene_result CURSOR FORSELECT blah blahORDER BY blah;FETCH $offset IN
gene_result");

$result->ntuple: returns only the number set by $offset, not TOTAL for query.

2) use LIMIT OFFSET

same problem,
$result->ntuple: returns only the number set by LIMIT, OFFSET, not 
TOTAL for query.

So there has to be a way to glean both the TOTAL and the SUBSET returned?

Searching the postgresql archives obviously can deal with this
http://archives.postgresql.org/pgsql-sql/
'Displaying documents 11-20 of total 243 found.'

-- 
Regards,
Chuck


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] postgresql 7.1 file descriptor
Следующее
От: Masaru Sugawara
Дата:
Сообщение: Re: blanking out repeated columns in rows